//
//  GPAMapManager.m
//  PFAmapDemo
//
//  Created by 原鹏飞 on 2018/10/31.
//  Copyright © 2018 ypf. All rights reserved.
//

#import "GPAMapManager.h"

@interface GPAMapManager ()

@property (nonatomic, strong) AMapLocationManager *locationManager;

@end

@implementation GPAMapManager

// 创建单例
+ (instancetype)sharedManager {
    static dispatch_once_t onceToken;
    static GPAMapManager *instance;
    dispatch_once(&onceToken, ^{
        instance = [[GPAMapManager alloc] init];
    });
    return instance;
}


- (NSString *)gp_currentCity {
    _locationManager = [[AMapLocationManager alloc] init];
    [_locationManager setDesiredAccuracy:kCLLocationAccuracyHundredMeters];
    _locationManager.locationTimeout = 2;
    _locationManager.reGeocodeTimeout = 2;
   
    __block NSString *cityName = @"";
    [self.locationManager requestLocationWithReGeocode:YES completionBlock:^(CLLocation *location, AMapLocationReGeocode *regeocode, NSError *error) {
        if (!error && regeocode) {
            NSLog(@"reGeocode:%@", regeocode);
            cityName = regeocode.city;
        }
    }];
    
    return cityName;
}


@end
